/*
 * price_model.hpp
 *
 *  Created on: Apr 1, 2009
 *      Author: Lev
 */

#ifndef PRICE_MODEL_HPP_
#define PRICE_MODEL_HPP_

#include <stdexcept>
#include "../statistics/random_generator.hpp"

struct SPModelProps {
	double s0;
	double mu;
	double sigma;
	SPModelProps& setInitialPrice( double sPrice ) { s0 = sPrice; return *this; }
	SPModelProps& setExpectedReturn( double eRet ) { mu = eRet; return *this; }
	SPModelProps& setVolatility( double sRms ) { sigma = sRms; return *this; }
};

class StockPriceModel {
private:
	double _s0; // initial price
	double _mu; // expected annual return
	double _sigma; // annual volatility
	NormalRandomNumber _random;
	double _sT; // current price at T
public:
	StockPriceModel( double s0 = 0 ) : _s0(s0), _mu(0), _sigma(0), _sT(s0) {}
	StockPriceModel( const SPModelProps& props )
		: _s0(props.s0), _mu(props.mu), _sigma(props.sigma), _sT(props.s0) {}
	double getInitialPrice() const { return _s0; }
	double getExpectedReturn() const { return _mu; }
	double getVolatility() const { return _sigma; }
	double getNextPrice( double dt ) throw(std::invalid_argument);
	void resetProps( const SPModelProps& props );
};

#endif /* PRICE_MODEL_HPP_ */
